<?php
class MY_Controller extends CI_Controller{
	
	function __construct(){
		parent::__construct();
	}
	
//	function _validate_cookie(){
//    	$this->load->library('session');
//    	
//    	//check login, no logged redirect to homepage
//    	if (!$this->session->userdata('logged') || !$this->session->userdata('usrname')){
//    		if (current_url() != base_url()) redirect(base_url());
//    	}
//    }
    
    function validateCookie(){
    	$true = md5('success');
    	if(get_cookie('logged')== $true){
    		return true;
    	} else {
    		redirect("dashboard/signup");
    		return false;
    	}
    }
    
	function _validateUser($usrname){
		//Validate cookie has been done
		//so, validate user here
		$this->load->library('session');
		$md5 = md5($this->session->userdata('usrname'));
		
		if ($usrname != $md5)  redirect('/', 'refresh');
	}
	
	function finalizeView($config){
		$this->load->view('dashboard',$config);
	}
	

	/**
	 * router signature call function from ajax request
	 * @param unknown_type $func_name
	 */
	function ajax($func_name, $a=false, $b=false, $c=false, $d=false){
		$this->{'_'.$func_name}($a, $b, $c, $d);
	}
	
}